calling a function inside a parent by detecting a call in the child in react